home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
QRZ! Ham Radio 1
/
QRZ Ham Radio Callsign Database - December 1993.iso
/
unix
/
nsort.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-11-02
|
824b
|
55 lines
#include "cb.h"
main(argc,argv)
int argc;
char *argv[];
{
int cmp_node();
caddr_t mc;
caddr_t mi;
caddr_t end;
struct stat st;
struct nind *idx;
struct nind key;
struct nind *found;
int dir;
long p;
long idsize;
int nel;
FILE *fp;
int IS = sizeof(struct nind);
if ((fp=fopen("nlist.ndx","r+")) == NULL)
{
printf("Error opening nlist.ndx\n");
exit(1);
}
fstat(fileno(fp),&st);
if ((mi = (caddr_t)mmap(NULL,st.st_size,PROT_READ|PROT_WRITE,MAP_SHARED,
fileno(fp),NULL)) == (caddr_t)NULL)
{
fprintf(stderr,"Error - mmap index file\n");
exit(1);
}
fclose(fp);
idsize = st.st_size/IS;
idx = (struct nind *)mi;
qsort((char *)idx, idsize, sizeof(struct nind), cmp_node);
munmap(mi,st.st_size);
exit(0);
}
cmp_node(i1,i2)
struct nind *i1, *i2;
{
return(strcmp(i1->name,i2->name));
}